

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class GUI_Serveur extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 539581897978347904L;
	private JPanel contentPane;
	private JLabel lblNbClient = new JLabel("0");
	private ObjetServeur objServeur;
	private Traitement_Serveur traitement;
	

	/**
	 * Create the frame.
	 */
	public GUI_Serveur(ObjetServeur ser) {
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent arg0) {
				objServeur.setTermine(true);
				
				try {
					traitement.join();
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				objServeur.sauvegardeBase();
			}
		});
		traitement = new Traitement_Serveur(ser);
		objServeur = ser;
		setTitle("Interface Serveur");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNombreDeClient = new JLabel("Nombre de client(s) connect\u00E9(s) :");
		lblNombreDeClient.setBounds(10, 27, 190, 14);
		contentPane.add(lblNombreDeClient);
		
		
		lblNbClient.setBounds(210, 27, 46, 14);
		contentPane.add(lblNbClient);
		traitement.start();
	}
	public void modifNbClient(int nbclient){
		lblNbClient.setText(Integer.toString(nbclient));
	}


}
